/*-*
 * FILENAME  :
 *    $HeadURL$
 *
 * STATUS  :
 *    $Revision$
 *
 *    $Author$
 *    $Date$
 *  
 *    
 * Copyright (c) 2011 Gonalge Ltda. All rights reserved.
 *
 ****************************************************************/

package org.gonalge.sudoku.util;

import javax.imageio.ImageIO;
import javax.swing.JFrame;

import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;

/**
 * 
 * @author Geremias Gonzalez
 */
public class FormUtils {

    public void centerScreen(JFrame frame) {
        Dimension dim = frame.getToolkit().getScreenSize();
        Rectangle abounds = frame.getBounds();
        frame.setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
        frame.requestFocus();
    }

    public BufferedImage getImagen(String name) {
        try {
            return ImageIO.read(getClass().getClassLoader().getResource("img/" + name + ".jpg"));
        } catch (Exception e) {
            System.out.println("Error de imagen");
            return null;
        }
    }

}
